package nongchang.kuaijiecaifu.com.ncapp_android.ui.adapter.basketadapter;

import android.content.Context;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import butterknife.ButterKnife;
import ezy.lite.util.ContextUtil;
import ezy.lite.util.UI;
import nongchang.kuaijiecaifu.com.ncapp_android.R;
import nongchang.kuaijiecaifu.com.ncapp_android.common.adapter.ItemAdapter;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.good.BasketMenu;
import nongchang.kuaijiecaifu.com.ncapp_android.retrofit.main.Home;
import nongchang.kuaijiecaifu.com.ncapp_android.ui.LifeShopActivity;

/**
 * Created by Administrator on 2016/4/26 0026.
 */
public class BasketMenuAdapter extends ItemAdapter<BasketMenu, BasketMenuAdapter.BasketMenuViewHolder> {
    private Context context;

    public BasketMenuAdapter(Context context) {
        super(context);
        this.context = context;
    }

    private View.OnClickListener onBackGround;

    public void setOnBackGround(View.OnClickListener onBackGround) {
        this.onBackGround = onBackGround;
    }

    @Override
    public BasketMenuViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BasketMenuViewHolder(inflate(R.layout.item_basket_menu, parent));
    }

    @Override
    public void onBindViewHolder(BasketMenuViewHolder holder, int position) {
        BasketMenu item = getItem(position);
        holder.txtName.setText(item.name);
        if (item.isselect) {
            Glide.with(context).load(item.selectedimage).into(holder.imgIcon);
            holder.txtName.setTextColor(0xFF2ABAAB);
        } else {
            Glide.with(context).load(item.selectimage).into(holder.imgIcon);
            holder.txtName.setTextColor(0xDD000000);
        }
        holder.linearLayout.setOnClickListener(onBackGround);
        holder.linearLayout.setTag(position);
    }


    static class BasketMenuViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.img_icon)
        ImageView imgIcon;
        @BindView(R.id.txt_name)
        TextView txtName;
        @BindView(R.id.ll_layout)
        LinearLayout linearLayout;

        public BasketMenuViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

    }
}
